package com.abvnet.project.water.project.service;

import com.abvnet.common.utils.text.Convert;
import com.abvnet.project.water.project.domain.ProjectProgress;
import com.abvnet.project.water.project.mapper.ProjectProgressMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 项目进度 服务层实现
 * 
 * @author duj
 * @date 2019-07-23
 */
@Service
public class ProjectProgressServiceImpl implements IProjectProgressService {
	@Autowired
	private ProjectProgressMapper projectProgressMapper;

	/**
     * 查询项目进度信息
     * 
     * @param progressId 项目进度ID
     * @return 项目进度信息
     */
    @Override
	public ProjectProgress selectProjectProgressById(Long progressId) {
	    return projectProgressMapper.selectProjectProgressById(progressId);
	}
	
	/**
     * 查询项目进度列表
     * 
     * @param projectProgress 项目进度信息
     * @return 项目进度集合
     */
	@Override
	public List<ProjectProgress> selectProjectProgressList(ProjectProgress projectProgress) {
	    return projectProgressMapper.selectProjectProgressList(projectProgress);
	}

    @Override
    public List<ProjectProgress> selectProjectProgressListByProjectId(Long projectId) {
        return projectProgressMapper.selectProjectProgressListByProjectId(projectId);
    }

    @Override
    public List<ProjectProgress> selectProjectProgressByProjectId(Long projectId) {
        return projectProgressMapper.selectProjectProgressByProjectId(projectId);
    }

    /**
     * 新增项目进度
     * 
     * @param projectProgress 项目进度信息
     * @return 结果
     */
	@Override
	public int insertProjectProgress(ProjectProgress projectProgress) {
	    return projectProgressMapper.insertProjectProgress(projectProgress);
	}
	
	/**
     * 修改项目进度
     * 
     * @param projectProgress 项目进度信息
     * @return 结果
     */
	@Override
	public int updateProjectProgress(ProjectProgress projectProgress) {
	    return projectProgressMapper.updateProjectProgress(projectProgress);
	}

    @Override
    public void batchUpdateProjectProgress(List<ProjectProgress> list) {
        list.stream().filter(p -> p.getUserId() != null).forEach(p -> projectProgressMapper.updateProjectProgress(p));
    }

    /**
     * 删除项目进度对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteProjectProgressByIds(String ids) {
		return projectProgressMapper.deleteProjectProgressByIds(Convert.toStrArray(ids));
	}
	
}